<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport">
<meta content="yes" name="apple-mobile-web-app-capable" />
<meta content="black" name="apple-mobile-web-app-status-bar-style" />
<meta content="telephone=no" name="format-detection" />
<title>我的评论</title>
<script src="js/jquery.min.js" ></script>
<script src="js/common.js" ></script>
<!--消息 脚本-->
<link rel="stylesheet" href="css/amazeui.min.css">
<script src="js/amazeui.min.js"></script>
<!--消息 脚本-->
<!--标准mui.css-->
<link rel="stylesheet" href="css/mui.min.css">
<!--App自定义的css-->
<link rel="stylesheet" type="text/css" href="css/base.css">
<link rel="stylesheet" type="text/css" href="css/common.css">
<style>
.mui-segmented-control{ background-color:#fff; border:none; border-bottom:1px solid #dddddd;} 
.mui-segmented-control .mui-control-item{ font-size:14px; color:#4c4c4c; border-left:none; }
.mui-segmented-control .mui-control-item.mui-active{border-bottom:2px solid #dd2727; background-color:transparent; color:#dd2727; }
</style>
</head>

<body>
	<div id="indexVm" v-cloak>
  <header class="header mui-bar mui-bar-nav">
    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
	<h1 class="mui-title">我的评论</h1>
    <div class="am-dropdown" data-am-dropdown>
      <span class="am-btn am-dropdown-toggle" data-am-dropdown-toggle><em class="header-notice-tips"></em></span>
      <ul class="am-dropdown-content">
      	<li class="clearfix"><a href="message.html"><i><img src="images/header-notice.png"></i>消息<em v-bind:class="messagenum>0?'header-notice-tips fr':''"></em></a></li>
        <li><a href="index.html"><i><img src="images/header-home.png"></i>首页</a></li>
      </ul>
    </div>
  </header>
  <!--header-end-->
<div class="mui-content">
  <div id="segmentedControl" class="mui-segmented-control">
      <a class="mui-control-item mui-active" href="#item1">发出的评论</a>
  </div>
  <div id="item1" class="mui-control-content mui-active">
    <div class="comments-list" v-for="wsConsulation in wsConsulationList">
      <div class="comments-list-top display-box-middle">
        <div class="comments-list-top-l"><img v-bind:src="wsConsulation.headimgurl"></div>
        <div class="comments-list-top-r">
          <div class="tit-time clearfix">
            <span class="fl">{{wsConsulation.nickname}}</span>
            <span class="fr">{{wsConsulation.createDate}}</span>
          </div>
          <div class="txt-del">
            <span class="fl">{{wsConsulation.consulationContent}}</span>
            <span class="fr" v-bind:onclick="'deleteConsulation(\''+wsConsulation.id+'\')'">删除</span>
          </div>
        </div>
      </div>
      <div class="comments-list-bot display-box-middle">
        <div class="comments-list-bot-l"><img v-bind:src="wsConsulation.thumb"></div>
        <div class="comments-list-bot-r">
          <span>{{wsConsulation.productTitle}}</span>
          <div class="comments-list-bot-price">
            <em>￥</em>       
            <strong>{{wsConsulation.reallyUnitPrice}}</strong>
          </div>
        </div>
      </div> 
    </div>
    
  </div>
</div>
</div>
<!--container-end-->
<script src="js/mui.min.js"></script>
<script src="js/wxshop.js"></script>
<script src="js/vue.js"></script>
<script>
	var citys;
	var cityArray= new Array();
	var vm = new Vue({
		el: '#indexVm',
		data: {
			messagenum: "",
			wsConsulationList:[],
		},
		created: function () {
			mui.ajax(wxshop.serverUrl+"/consulation", {
				type: "post",
				data:{
					code:wxshop.getUrlParam("code"),
				},
				dataType: "json",
				success: function(data) {
					if(data.ret==0){
						mui.alert(data.msg);
					}
					if(data.ret==2){
						wxshop.getOpenId(data.appid);
					}	
					vm.messagenum=data.messagenum;
					vm.wsConsulationList=data.wsConsulationList;
					vm.$nextTick(function () {
						mui.init({
							swipeBack:true //启用右滑关闭功能
						});
						mui('#scroll').scroll({
							indicators: true //是否显示滚动条
						});
						var segmentedControl = document.getElementById('segmentedControl');
					})
				},
				error: function() {
					mui.alert("后台接口请求失败，请联系管理员！错误"+errorThrown);
				}
			});
		},
	});
	//删除评论
	function deleteConsulation(consulationId){
		mui.ajax(wxshop.serverUrl+"/consulation/delete", {
				type: "post",
				data:{
					code:wxshop.getUrlParam("code"),
					consulationId:consulationId,
				},
				dataType: "json",
				success: function(data) {
					if(data.ret==0){
						mui.alert(data.msg);
						return;
					}
					mui.alert("删除评论成功");
					vm.wsConsulationList=data.wsConsulationList;
					vm.$nextTick(function () {
						mui.init({
							swipeBack:true //启用右滑关闭功能
						});
						mui('#scroll').scroll({
							indicators: true //是否显示滚动条
						});
						var segmentedControl = document.getElementById('segmentedControl');
					})
				},
				error: function(xhr,type,errorThrown) {
					mui.alert("后台接口请求失败，请联系管理员！错误"+errorThrown);
				}
		});
	}
</script>
</body>
</html>
